using Microsoft.Extensions.DependencyInjection;

using Tszy.API.Test1;
using Tszy.Unlimited.Base;

namespace Tszy.APITest
{
    public class UnitTest1
    {
        [Fact]
        public void Test1()
        {
            var services = Starter.OnApplicationStart();

            using (var scope = services.CreateScope())
            {
                var controller = scope.ServiceProvider.GetService<HomeController>();

                if (controller != null)
                {
                    controller.Test1(new Test11.Request());
                }
            }

        }
    }

    public class Starter
    {
        public static IServiceProvider OnApplicationStart()
        {
            var services = new ServiceCollection();

            services.AddTransient<HomeController>();
            services.AddTransient<Test11>();
            services.RegisterTszyComponent();

            return ConfigureServices(services);
        }

        public static IServiceProvider ConfigureServices(IServiceCollection services)
        {
            return services.BuildServiceProvider();
        }
    }
}